	var lk_preview_img_top=0;//为了定位小图片的位置
	var lk_preview_img_left=0;//
	var lk_preview_img_width=-120;//小图片宽度
	var lk_preview_img_height=300;//调整预览图的高度
	
	function lk_preview_bind(){//信息块事件的绑定方法,为了在局部刷新时,调用这个方法,给新刷出来的小图绑定事件
		$(".lk_small_img").unbind();//避免重复绑定	
		$(".lk_small_img").bind({//小图片绑定事件
			mouseout:function(){//离开时,预览图隐藏
				if($("#lk_preview_img_big").css("display")=="block"){
					$("#lk_preview_img_big").css("display","none");
				}
			},
			mouseenter:function(){//触碰时,预览图出现
				if($("#lk_preview_img_big").css("display")=="none"){
					var lk_preview_img_big_src=$(this).attr("src");//获取小图链接
					$("#lk_preview_img_big img").attr("src",lk_preview_img_big_src);//为预览图填充链接
					$("#lk_preview_img_big").fadeIn("fast").css({top:$(this).offset().top-lk_preview_img_height,left:($(this).offset().left+lk_preview_img_width)});//预览图显示以及位置的调整
				}
			}
		});
	
		$(".lk_preview_img_moreInfo,.lk_preview_img_ControlDiv").unbind();//避免重复绑
		$(".lk_preview_img_moreInfo,.lk_preview_img_ControlDiv").bind("click",function(){//图片显示块的隐藏
			var lk_ico_id=$(this).attr("class");
			if($(this).children("span").text()=="点击展开" ){
				$(this).children("span").text("点击收缩");
				if(lk_ico_id=="lk_preview_img_moreInfo"){
					$(this).next().slideDown("fast");
				}else{
					$(this).next().slideDown("fast");
				}
			}else{
				$(this).children("span").text("点击展开");
				if(lk_ico_id=="lk_preview_img_moreInfo"){
					$(this).next().slideUp("fast");
				}else{
					$(this).next().slideUp("fast");
				}
			}
		});	
		
		//关注事件
		$(".lk_index_taskInfo_button_2").unbind();//避免重复绑
		$(".lk_index_taskInfo_button_2").bind("click",function(){
			var currentUserPhoto=$("#currentUserPhoto").attr("photo");
		    if(currentUserPhoto==""){
		    	swal({
		    		  title: "请先登陆哦!",
		    		  text: "您是否要跳转到登陆页面?",
		    		  type: "info",
		    		  showCancelButton: true,
		    		  confirmButtonColor: "#DD6B55",
		    		  confirmButtonText: "好的,我要登陆!",
		    		  cancelButtonText:"我现在不想登陆",
		    		  closeOnConfirm: false
		    		},
		    		function(){
		    		  location.href="login.html";
		    		});
		    	return;
		    }else{
		    	//在页面提示用户  防止多余的请求提交
				//Ajax发请求修改任务状态
				var lk_care_button=$(this);
				var lk_care_tid=$(this).attr("tid");
				var lk_care_status=$(this).attr("status");
				$.ajax({
					type:"POST",
					url:"task.action",
					data:"op=careTask&tid="+lk_care_tid+"&status="+lk_care_status,
					dataType:"JSON",
					success: function(data){
						if(data.code==1){
							//data.obj[0] 0表示关注, 1表示已经关注过了, 2表示取消关注
							//data.obj[2] 表示当前任务关注人数
							var lk_care_message="";
							if(data.obj[2]!="0"){
								data.obj[2]="("+data.obj[2]+")";
							}else{
								data.obj[2]="";
							}
							if("0"==data.obj[0]){
								lk_care_button.css("color","#F90").text("已关注"+data.obj[2]);
								lk_care_message="关注成功";
								lk_care_button.attr("status","已关注");
								//关注数+1
								$("#yhj_content_maincontent_right_userinfo_content_guanzhu a").text(($("#yhj_content_maincontent_right_userinfo_content_guanzhu a").text()-0)+1)
							}else if("1"==data.obj[0]){
								lk_care_button.css("color","#F90").text("已关注"+data.obj[2]);
								lk_care_message="您已经关注过了哦";
							}else if("2"==data.obj[0]){
								lk_care_button.css("color","#000").text("关注"+data.obj[2]);
								lk_care_message="取消关注成功";
								lk_care_button.attr("status","关注");
								$("#yhj_content_maincontent_right_userinfo_content_guanzhu a").text($("#yhj_content_maincontent_right_userinfo_content_guanzhu a").text()-1)
							}
							
							if("1"==data.obj[0]){
								sweetAlert(lk_care_message);
							}else{
								swal("操作成功!", lk_care_message, "success")
							}
						}else{
							sweetAlert(data.msg);
						}
					}
				});
		    }
		});
		//接收事件
		$(".lk_index_taskInfo_button_1").unbind();//避免重复绑
		$(".lk_index_taskInfo_button_1").bind("click",function(){
			var currentUserPhoto=$("#currentUserPhoto").attr("photo");
		    if(currentUserPhoto==""){
		    	swal({
		    		  title: "请先登陆哦!",
		    		  text: "您是否要跳转到登陆页面?",
		    		  type: "info",
		    		  showCancelButton: true,
		    		  confirmButtonColor: "#DD6B55",
		    		  confirmButtonText: "好的,我要登陆!",
		    		  cancelButtonText:"我现在不想登陆",
		    		  closeOnConfirm: false
		    		},
		    		function(){
		    		  location.href="login.html";
		    		});
		    	return;
		    }
		    //用于判断刚刚自己发布的任务;
		    if($(this).attr("tid")==null){
		    	sweetAlert("不能接收自己的任务");
		    	return;
		    }
			//在页面提示用户  防止多余的请求提交
			if($(this).text()=="已接收"){
				sweetAlert("已经有人接收了该任务");
				return;
			}else{
				//Ajax发请求修改任务状态
				var lk_accept_button=$(this);
				var lk_accept_tid=$(this).attr("tid");
				$.ajax({
					type:"POST",
					url:"task.action",
					data:"op=acceptTask&tid="+lk_accept_tid,
					dataType:"JSON",
					success: function(data){
						if(data.code==1){
							lk_accept_button.css("color","#F90").text("已接受")
							swal("操作成功", "恭喜您,接受任务成功!", "success");
						}else{
							sweetAlert(data.msg);
						}
					}
				});
			}
		});
		//屏蔽事件
		$(".lk_index_taskInfo_button_4").unbind();//避免重复绑
		$(".lk_index_taskInfo_button_4").bind("click",function(){
			var currentUserPhoto=$("#currentUserPhoto").attr("photo");
		    if(currentUserPhoto==""){
		    	swal({
		    		  title: "请先登陆哦!",
		    		  text: "您是否要跳转到登陆页面?",
		    		  type: "info",
		    		  showCancelButton: true,
		    		  confirmButtonColor: "#DD6B55",
		    		  confirmButtonText: "好的,我要登陆!",
		    		  cancelButtonText:"我现在不想登陆",
		    		  closeOnConfirm: false
		    		},
		    		function(){
		    		  location.href="login.html";
		    		});
		    	return;
		    }
		    //用于判断刚刚自己发布的任务;
		    if($(this).attr("tid")==null){
		    	sweetAlert("不能屏蔽自己的任务!");
		    	return;
		    }else{
				//Ajax发请求修改任务状态
				var lk_shield_tid=$(this).attr("tid");
				var lk_shield_button=$(this);
				$.ajax({
					type:"POST",
					url:"task.action",
					data:"op=shieldTask&tid="+lk_shield_tid,
					dataType:"JSON",
					success: function(data){
						if(data.code==1){
							lk_shield_button.css("color","#F90").text("已屏蔽");
							swal("操作成功!", "恭喜您,屏蔽该任务成功!", "success")
						}else {
							sweetAlert(data.msg);
						}
					}
				});
			}
		});
		
		
	}
	
	function lk_reply_bind(){//信息块事件的绑定方法,为了在局部刷新时,调用这个方法,给新刷出来的	
		//举报span出现事件
		$(".lk_index_taskInfo_discuss_list_info").unbind();//避免重复绑
		$(".lk_index_taskInfo_discuss_list_info").bind({
			mouseenter:function(){
				var obj=$(this).children("div").eq(1).children("div").eq(1).children(".lk_index_taskInfo_discuss_list_info_contents_statuts_report");//获取举报span对象
				obj.css("display","block");//span显示
				obj.prev().css("display","block");//竖线显示	
				$(this).children(".lk_index_taskInfo_discuss_list_info_contents_statuts_report").css("display","block");
			},
			mouseleave:function(){
				var obj=$(this).children("div").eq(1).children("div").eq(1).children(".lk_index_taskInfo_discuss_list_info_contents_statuts_report");//获取举报span对象		
				obj.prev().css("display","none");
				obj.css("display","none");
				$(this).children(".lk_index_taskInfo_discuss_list_info_contents_statuts_report").css("display","none");
			}
		});
		
		//评论赞同事件
		$(".lk_index_taskInfo_discuss_list_info_contents_statuts_sustain").unbind();//避免重复绑
		$(".lk_index_taskInfo_discuss_list_info_contents_statuts_sustain").bind("click",function(){
			var currentUserPhoto=$("#currentUserPhoto").attr("photo");
		    if(currentUserPhoto==""){
		    	swal({
		    		  title: "请先登陆哦!",
		    		  text: "您是否要跳转到登陆页面?",
		    		  type: "info",
		    		  showCancelButton: true,
		    		  confirmButtonColor: "#DD6B55",
		    		  confirmButtonText: "好的,我要登陆!",
		    		  cancelButtonText:"我现在不想登陆",
		    		  closeOnConfirm: false
		    		},
		    		function(){
		    		  location.href="login.html";
		    		});
		    	return;
		    }else{
		    	var rid=$(this).attr("rid");//获取评论id
		    	var obj=$(this);
		    	$.ajax({
					type:"POST",
					url:"reply.action",
					data:"op=supportReply&rid="+rid,
					dataType:"JSON",
					success: function(data){
						if(data.code==1){
							obj.text("赞同 "+data.obj );
						}
					}
				});
		    }
		});
		
		//回复别人的评论块
		$(".lk_index_taskInfo_discuss_list_info_contents_statuts_reply").unbind();//避免重复绑
		$(".lk_index_taskInfo_discuss_list_info_contents_statuts_reply").bind("click",function(){
			var currentUserPhoto=$("#currentUserPhoto").attr("photo");
		    if(currentUserPhoto==""){
		    	swal({
		    		  title: "请先登陆哦!",
		    		  text: "您是否要跳转到登陆页面?",
		    		  type: "info",
		    		  showCancelButton: true,
		    		  confirmButtonColor: "#DD6B55",
		    		  confirmButtonText: "好的,我要登陆!",
		    		  cancelButtonText:"我现在不想登陆",
		    		  closeOnConfirm: false
		    		},
		    		function(){
		    		  location.href="login.html";
		    		});
		    	return;
		    }
			if($(this).parent().parent().parent().next().css("display")=="none"){
				//记录回复对象的名字
				var reply_name=$(this).parent().prev().children(".lk_index_taskInfo_discuss_list_info_contents_viewpoint_name").text();
				//记录input内容信息
				var reply_obj=$(this).parent().parent().parent().next().css("display","block").children().val();
				//用于判断是否需要刷新input内容信息
				var reply_str="回复@"+reply_name+":";
				if(reply_obj.length>=reply_str.length){
					//先清空,再填充,为了去除文字全选的效果
					$(this).parent().parent().parent().next().css("display","block").children().val("").select().val(reply_obj)
				}else{
					$(this).parent().parent().parent().next().css("display","block").children().select().val("回复@"+reply_name+":");
				}
			}else{
				//input失去焦点事件
				$(this).parent().parent().parent().next().css("display","none").children().blur();
			}
		});
		
		//评论块点击弹出事件
		$(".lk_index_taskInfo_button_3").unbind();//避免重复绑
		$(".lk_index_taskInfo_button_3").bind("click",function(){
			if($(this).parent().next().css("display")=="none"){
				$(this).parent().next().slideDown("fast").children("div :eq(1)").children().children("div :eq(1)").children().select();//选择input
				//取到回复块的对象
				var replyObj= $(this).parent().next().children('.lk_index_taskInfo_discuss_list').children('.lk_reply_list_show');
				//用ajax 向服务器请求该任务的评论信息
				$.ajax({
					type:"POST",
					url:"task.action",
					data:"op=findTaskReply&tid="+$(this).attr("tid"),
					dataType:"JSON",
					success: function(data){
						var tablestring="";
						for(var i=0;i<data.obj.length;i++){
							var item=data.obj[i];
							if(item.robj=="0"){//item.robj  默认为0 表示是对该任务的评论						
								//对时间戳进行裁剪
								item.rdatetime=lk_showTime( ( (item.rdatetime).substring(0, 16) ),"reply");
								//对评论赞数处理,没有人时,为null,优化显示效果
								if(item.rsupportid=="null"){
									item.rsupportid="0";
								}
								//中间加其他的html代码 
								tablestring+='<div><div class="lk_index_taskInfo_discuss_list_info"><div class="lk_index_taskInfo_discuss_list_info_head"><img src="images/headphotos/'+item.uimage+'"/></div><div class="lk_index_taskInfo_discuss_list_info_contents"><div class="lk_index_taskInfo_discuss_list_info_contents_viewpoint"><span class="lk_index_taskInfo_discuss_list_info_contents_viewpoint_name">'+item.ualais+'</span><span class="lk_index_taskInfo_discuss_list_info_contents_viewpoint_info">:'+item.rcontent+'</span></div><div class="lk_index_taskInfo_discuss_list_info_contents_statuts"><span class="lk_index_taskInfo_discuss_list_info_contents_statuts_time">'+item.rdatetime+'</span><span class="lk_index_taskInfo_discuss_list_info_contents_statuts_sustain" rid="'+item.rid+'">赞同 '+item.rsupportid+'</span><span class="lk_index_taskInfo_discuss_list_info_contents_statuts_line">|</span><span class="lk_index_taskInfo_discuss_list_info_contents_statuts_reply" >回复</span><span class="lk_index_taskInfo_discuss_list_info_contents_statuts_line_2">|</span><span class="lk_index_taskInfo_discuss_list_info_contents_statuts_report">举报</span></div></div></div><div class="lk_index_taskInfo_discuss_list_info_contents_viewpoint_reply"><input type="text"/><div  class="lk_index_taskInfo_discuss_input_div_send" tid="'+item.tid+'" rid="'+item.rid+'">评论</div></div><div class="lk_index_taskInfo_discuss_list_info_line"></div></div>';
								tablestring=lk_findChildrenReply(data,tablestring,item.rid);
							}
						}
						replyObj.html(tablestring);
						//为新刷出来的内容绑定事件
						lk_reply_bind();
					}
				});
				
			}else{
				$(this).parent().next().slideUp("fast");
			}
		});	
		
		//回复信息事件
		$(".lk_index_taskInfo_discuss_input_div_send").unbind();//避免重复绑
		$(".lk_index_taskInfo_discuss_input_div_send").bind("click",function(){
			var currentUserPhoto=$("#currentUserPhoto").attr("photo");
		    if(currentUserPhoto==""){
		    	swal({
		    		  title: "请先登陆哦!",
		    		  text: "您是否要跳转到登陆页面?",
		    		  type: "info",
		    		  showCancelButton: true,
		    		  confirmButtonColor: "#DD6B55",
		    		  confirmButtonText: "好的,我要登陆!",
		    		  cancelButtonText:"我现在不想登陆",
		    		  closeOnConfirm: false
		    		},
		    		function(){
		    		  location.href="login.html";
		    		});
		    	return;
		    }
			//判断是回复任务,还是回复用户
			var obj=$(this);
			var lk_objClass=obj.parent().attr("class");
			var lk_length=0;
			var lk_flag=0;
			var discuss_info;//发表的评论
			if(lk_objClass=="lk_index_taskInfo_discuss_input_div"){//对任务的评论的this 父类class
				discuss_info=obj.prev().children("input").val();
				lk_flag=1;
				lk_length=discuss_info.length;
				//添加评论任务信息
				$.ajax({
					type:"POST",
					url:"reply.action",
					data:"op=addTaskReply&rcontent="+discuss_info+"&tid="+$(this).attr("tid"),
					dataType:"JSON",
					success: function(data){
						if(data.code==1){
							//用js显示信息在主页面上
							lk_JsShowTaskReply(obj,discuss_info,lk_length,lk_flag,data.obj.rid,data.obj.tid);
							lk_reply_bind();
						}else{
							sweetAlert(data.msg);
						}
					}
				})
			}else if(lk_objClass=="lk_index_taskInfo_discuss_list_info_contents_viewpoint_reply"){//对评论的评论的this 父类class				
				discuss_info="<font style='color:blue'>"+obj.prev().val()+"</font>";
				lk_flag=2;
				lk_length=discuss_info.length;//需要优化判断  对于是否要自动恢复用户名字的bug
				//添加评论任务信息
				$.ajax({
					type:"POST",
					url:"reply.action",
					data:"op=addTaskReply&rcontent="+discuss_info+"&tid="+$(this).attr("tid")+"&rid="+$(this).attr("rid"),
					dataType:"JSON",
					success: function(data){
						if(data.code==1){
							//用js显示信息在主页面上
							lk_JsShowTaskReply(obj,discuss_info,lk_length,lk_flag,data.obj.rid,data.obj.tid);
							lk_reply_bind();
						}else{
							sweetAlert(data.msg);
						}
					}
				})
			}
			
		});
	}
	
	$(function(){
		//下拉刷新任务
		/*window.onscroll=function(){
			放在了yhj_index.js里面了
		}*/
		
		//绑定左边分类查询
		$("#lk_content_maincontent_left_taskType li").bind("click",function(){
			//到达最上面先
			$(window).scrollTop(0);
			$("#lk_task_list_show_refreshTip h1").text("正在拼命查询中...请等待...");
			$("#lk_task_list_show_refreshTip").css("display","none");
			$("#lk_content_maincontent_left_taskType li").removeClass("yhj_content_maincontent_left_select");
			$(this).attr("class","yhj_content_maincontent_left_select");
			lk_indexFindTask($(this).attr("ttid"),$(".yhj_content_maincontent_center_smallcontent_select:eq(0)").attr("limit"));
		})
		//绑定中间的时间查询
		$("#lk_content_maincontent_center_timeLimit li").bind("click",function(){
			$("#lk_task_list_show_refreshTip h1").text("正在拼命查询中...请等待...");
			$("#lk_task_list_show_refreshTip").css("display","none");
			$("#lk_content_maincontent_center_timeLimit li").removeClass("yhj_content_maincontent_center_smallcontent_select");
			$(this).attr("class","yhj_content_maincontent_center_smallcontent_select");
			lk_indexFindTask($(".yhj_content_maincontent_left_select:eq(0)").attr("ttid"),$(this).attr("limit"));
		})
		
		//图片预览的调用
		new uploadPreview({ UpBtn: "lk_taskPhotoButton", DivShow: "lk_taskPhotodiv", ImgShow: "lk_taskPhoto" });
		$("#lk_taskPhotoButton_click").bind("click",function(){
			$("#lk_taskPhotoButton").click();
			$("#lk_content_maincontent_selectDate").slideUp();
			$("#lk_content_maincontent_ImagePreview").slideDown();
		});
		$("#lk_content_maincontent_ImagePreview_close").bind("click",function(){
			$("#lk_content_maincontent_ImagePreview").slideUp();
		});
		//期限选择
		$("#lk_taskDateButton_click").bind("click",function(){
			var DateObj=$("#lk_content_maincontent_selectDate");
			if(DateObj.css("display")=="block"){
				$("#lk_content_maincontent_selectDate").slideUp();
			}else{
				$("#lk_content_maincontent_ImagePreview").slideUp();
				$("#lk_content_maincontent_selectDate").slideDown();
			}
		});
		
		//TODO查询所有的任务
		lk_indexFindTask("0","0","0");
		$("#yhj_content_maincontent_center_quicksend_submit").click(function(){
			var currentUserPhoto=$("#currentUserPhoto").attr("photo");
		    if(currentUserPhoto==""){
		    	swal({
		    		  title: "请先登陆哦!",
		    		  text: "您是否要跳转到登陆页面?",
		    		  type: "info",
		    		  showCancelButton: true,
		    		  confirmButtonColor: "#DD6B55",
		    		  confirmButtonText: "好的,我要登陆!",
		    		  cancelButtonText:"我现在不想登陆",
		    		  closeOnConfirm: false
		    		},
		    		function(){
		    		  location.href="login.html";
		    		});
		    	return;
		    }
			var lk_treward=$("#treward");
			var lk_tmore=$("#tmore");
			var lk_taddr=$("#taddr");
			var lk_tweather=$("#tweather");
			var lk_tdate=$("#tdate");
			if(lk_treward.val()==""||lk_tmore.val()==""||lk_taddr.val()=="" ||lk_tweather.val()=="" ||lk_tdate.val()==""){
				sweetAlert("信息请完善再提交");
				return;	
			}
			//先判断是否有图片信息,
			var lk_taskPhoto_boolean=$("#lk_taskPhoto").attr("src");
			if(lk_taskPhoto_boolean){
				//上传图片信息到服务器,
				$.ajaxFileUpload({
					url:'photoUpload.action',
					secureuri:false,//上传的时候是否使用安全协议https而不是使用http
					type:'POST',
					dataType:'json',
					fileElementId:'lk_taskPhotoButton',//上传的文件域的id
					success:function(data){
						$("#lk_TaskTphoto").val(data.obj);//将图片信息存到对应的input
						//上传成功后得到一个图片名,将图片名传递给插入任务的ajax
						lk_insertTask(lk_treward,lk_tmore,lk_taddr,lk_tweather,lk_tdate);
					}
				});
			}else{
				//没有图片的添加任务
				lk_insertTask(lk_treward,lk_tmore,lk_taddr,lk_tweather,lk_tdate);
			}
		});	
	});
	
	//用于在调用js填充评论时间数据时  把评论的时间格式化
	function lk_showNowTime(){
		var nowdata=new Date();
		var year=nowdata.getFullYear();
		var month=nowdata.getMonth()+1;
		var day=nowdata.getDate();
		var hours=nowdata.getHours();
		var minutes=nowdata.getMinutes();
		if(month<10){
			month="0"+month;
		}
		if(day<10){
			day="0"+day;
		}
		if(hours<10){
			hours="0"+hours;
		}
		if(minutes<10){
			minutes="0"+minutes;
		}
		return year+"-"+month+"-"+day+" "+hours+":"+minutes;
	}

	
	//用js的方法在页面显示用户刚刚自己发出评论信息
	//在这里用节点拼接 是因为比字符串好维护些
	//字符串不好找位置填充,而节点可以选择位置插入
	function lk_JsShowTaskReply(obj,discuss_info,lk_length,lk_flag,rid,tid){
		//用js在页面显示消息
		if(lk_length>0 && lk_flag!=0){		
			var discuss_img=$("#currentUserPhoto").attr("src");//个人头像路径
			var discuss_name=$("#currentUser").text();	//个人名字
			var discuss_time=lk_showTime( lk_showNowTime(),"reply" );//评论时间

			var mainDiv=$('<div></div>');//主块
			var div1=$('<div class="lk_index_taskInfo_discuss_list_info"></div>');//大块
			var div2=$('<div class="lk_index_taskInfo_discuss_list_info_head"><img src="'+discuss_img+'"/></div>');//头像块
			var div3=$('<div class="lk_index_taskInfo_discuss_list_info_contents_viewpoint"></div>');//名字+评论信息块
			var div4=$('<div class="lk_index_taskInfo_discuss_list_info_contents"></div>');//内容块
			var div6=$('<div class="lk_index_taskInfo_discuss_list_info_contents_statuts"></div>');//状态块
			div6.html('<span class="lk_index_taskInfo_discuss_list_info_contents_statuts_time">'+discuss_time+'</span><span class="lk_index_taskInfo_discuss_list_info_contents_statuts_sustain" rid="'+rid+'">赞同 0</span><span  class="lk_index_taskInfo_discuss_list_info_contents_statuts_line">|</span><span  class="lk_index_taskInfo_discuss_list_info_contents_statuts_reply">回复</span><span  class="lk_index_taskInfo_discuss_list_info_contents_statuts_line_2">|</span><span  class="lk_index_taskInfo_discuss_list_info_contents_statuts_report">举报</span>');//填充状态块
			div3.html('<span class="lk_index_taskInfo_discuss_list_info_contents_viewpoint_name">'+discuss_name+'</span><span class="lk_index_taskInfo_discuss_list_info_contents_viewpoint_info">:'+discuss_info+'</span>');//填充名字+回复信息
			div4.append(div3,div6);//往内容块添加个人信息节点
			div1.append(div2,div4);//往大块添加头像块和内容块
			var div7=$('<div class="lk_index_taskInfo_discuss_list_info_contents_viewpoint_reply"><input type="text"/><div class="lk_index_taskInfo_discuss_input_div_send" rid="'+rid+'" tid="'+tid+'">评论</div></div>');//对回复的评论块
            var div8=$('<div class="lk_index_taskInfo_discuss_list_info_line"></div>');//分割线
			mainDiv.append(div1,div7,div8);//评论块完成
			if(lk_flag==1){//对任务得评论
				var target=obj.parents(".lk_index_taskInfo_discuss_input").next().children(".lk_reply_list_show");
				//alert(target.attr("class"))
				target.append(mainDiv);//最新的消息永远在最下面  需要优化
				obj.prev().children("input").val("");
			}else if(lk_flag==2){//对用户的评论
				mainDiv.insertAfter(obj.parent().parent() );
				obj.parent().css("display","none");
			}
		}
	}
	
	 //如果登陆了,将评论区域的默认头像改为用户的头像
	function lk_changeUserPhoto(){
    	var currentUserPhoto=$("#currentUserPhoto").attr("photo");
	    if(currentUserPhoto!=""){
	    	$(".lk_index_taskInfo_discuss_input_div_head_img").attr("src","images/headphotos/"+currentUserPhoto);	
	    }
    }
	
	//用递归的算法查询子评论的方法 
	function lk_findChildrenReply(data,str,rid){
		//判断是否有子评论
		for(var j=0;j<data.obj.length;j++){
			var itemChildren=data.obj[j];
			//添加子评论
			if(itemChildren.robj==rid ){
				//对时间戳进行裁剪
				itemChildren.rdatetime=(itemChildren.rdatetime).substring(0, 16);
				//对评论数处理,没有人时,为null,优化显示效果
				if(itemChildren.rsupportid=="null"){
					itemChildren.rsupportid="0";
				}
				str+='<div><div class="lk_index_taskInfo_discuss_list_info"><div class="lk_index_taskInfo_discuss_list_info_head"><img src="images/headphotos/'+itemChildren.uimage+'"/></div><div class="lk_index_taskInfo_discuss_list_info_contents"><div class="lk_index_taskInfo_discuss_list_info_contents_viewpoint"><span class="lk_index_taskInfo_discuss_list_info_contents_viewpoint_name">'+itemChildren.ualais+'</span><span class="lk_index_taskInfo_discuss_list_info_contents_viewpoint_info">:'+itemChildren.rcontent+'</span></div><div class="lk_index_taskInfo_discuss_list_info_contents_statuts"><span class="lk_index_taskInfo_discuss_list_info_contents_statuts_time">'+itemChildren.rdatetime+'</span><span class="lk_index_taskInfo_discuss_list_info_contents_statuts_sustain" rid="'+itemChildren.rid+'">赞同 '+itemChildren.rsupportid+'</span><span class="lk_index_taskInfo_discuss_list_info_contents_statuts_line">|</span><span class="lk_index_taskInfo_discuss_list_info_contents_statuts_reply" >回复</span><span class="lk_index_taskInfo_discuss_list_info_contents_statuts_line_2">|</span><span class="lk_index_taskInfo_discuss_list_info_contents_statuts_report">举报</span></div></div></div><div class="lk_index_taskInfo_discuss_list_info_contents_viewpoint_reply"><input type="text"/><div  class="lk_index_taskInfo_discuss_input_div_send" tid="'+itemChildren.tid+'" rid="'+itemChildren.rid+'">评论</div></div><div class="lk_index_taskInfo_discuss_list_info_line"></div></div>';
				str=lk_findChildrenReply(data,str,itemChildren.rid);
			}
		}
		return str;
	}
	
	//将显示的时间改为今天
	function lk_showTime(time,reply){
		var nowDay=( lk_showNowTime() ).substring(0, 10);
		var timeMore="";
		if(reply=="reply"){
			timeMore=time.substring(10, 16);// 对于在评论区域,要加小时分钟
		}
		time=time.substring(0, 10);
		//显示为今天
		if(time==nowDay){
			return "今天"+timeMore;
		}else{
			return time+timeMore;
		}
	}
	
	
	//向数据库中插入任务信息
	function lk_insertTask(lk_treward,lk_tmore,lk_taddr,lk_tweather,lk_tdate){
		//查看图片信息 alert($("#lk_TaskTphoto").val());
		$.ajax({
			type:"POST",
			url:"task.action",
			data:$("#lk_indexTaskForm").serialize(),
			dataType:"JSON",
			success: function(data){
				if(data.code==1){
					var item=data.obj;
					item.tsendtime=lk_showTime( (item.tsendtime).substring(0, 10) );
					var lk_task_status="关注";//关注状态
					var tablestring='<div class="yhj_content_maincontent_center_conternt"><div class="lk_taskInfo_person"><div class="lk_taskInfo_person_head"><img src="images/headphotos/'+item.uimage+'"/></div><div class="lk_taskInfo_person_info"><div class="lk_taskInfo_person_info_name">'+item.ualais+'</div><div class="lk_taskInfo_person_info_type"><ul><li>'+item.ttname+'</li></ul></div></div></div><div class="lk_index_taskInfo"><div class="lk_index_taskInfo_describe"><ul><li>'+item.tsendtime+'</li><li>天气:'+item.tweather+'</li><li>悬赏积分:'+item.treward+'</li><li>地点:'+item.taddr+'</li></ul></div><div class="lk_preview_img_moreInfo"><a>&nbsp;&nbsp;任务详情:</a><span class="lk_preview_img_ControlDiv_ico">点击展开</span></div><div class="lk_preview_img_moreInfoDiv">'+item.tmore+'</div><div class="lk_preview_img_ControlDiv"><a>&nbsp;&nbsp;任务相关图片:</a><span class="lk_preview_img_ControlDiv_ico">点击展开</span></div><div class="lk_preview_img_small"><img class="lk_small_img" src="images/taskPhoto/'+item.tphoto+'"/></div><div class="lk_index_taskInfo_buttonDiv"><div class="lk_index_taskInfo_button_1">审核中</div><div  class="lk_index_taskInfo_button_line"></div><div class="lk_index_taskInfo_button_2" status="'+lk_task_status+'" tid="'+item.tid+'">'+lk_task_status+'</div><div  class="lk_index_taskInfo_button_line"></div><div class="lk_index_taskInfo_button_3" tid="'+item.tid+'">评论</div><div  class="lk_index_taskInfo_button_line"></div><div class="lk_index_taskInfo_button_4">屏蔽</div></div><div class="lk_index_taskInfo_discuss"><div class="lk_index_taskInfo_discuss_triangle"></div><div class="lk_index_taskInfo_discuss_input"><div class="lk_index_taskInfo_discuss_input_div"><div class="lk_index_taskInfo_discuss_input_div_head"><img class="lk_index_taskInfo_discuss_input_div_head_img" src="images/lk_cool_effects_img1.gif"/></div><div class="lk_index_taskInfo_discuss_input_div_input"><input type="text" maxlength="140"/></div><div class="lk_index_taskInfo_discuss_input_div_send" tid="'+item.tid+'">评论</div></div></div><div class="lk_index_taskInfo_discuss_list"><div class="lk_index_taskInfo_discuss_list_type"><ul><li>全部</li><li>|</li><li>热门</li></ul></div><div class="lk_reply_list_show"></div><div class="lk_index_taskInfo_skip"><a href="task.action?op=taskdetail&tid='+item.tid+'">查看该任务全部评论</a></div></div></div></div></div>';
					//显示刚刚发布的任务内容
					$("#lk_task_list_show").html(tablestring+$("#lk_task_list_show").html() );
					//为新刷出来的内容绑定事件
					lk_preview_bind();
					lk_reply_bind();
					swal("操作成功", "任务发布成功!", "success")
					//清空处理
					lk_treward.val("");
					lk_tmore.val("");
					lk_taddr.val("");
					lk_tweather.val("");
					lk_tdate.val("");
					//对图片预览区域上传后的处理
					$("#lk_content_maincontent_ImagePreview").slideUp("fast");
					$("#lk_content_maincontent_selectDate").slideUp("fast");
					$("#lk_TaskTphoto").val("model.jpg");
					$("#lk_taskPhoto").removeAttr("src");
					
					//求助数+1					
					$("#yhj_content_maincontent_right_userinfo_content_qiuzhu a").text(($("#yhj_content_maincontent_right_userinfo_content_qiuzhu a").text()-0)+1);
					//图片预览的调用
					new uploadPreview({ UpBtn: "lk_taskPhotoButton", DivShow: "lk_taskPhotodiv", ImgShow: "lk_taskPhoto" });
				}else{
					sweetAlert(data.msg);
				}
			}
		});
	}
	
	//ajax刷出首页任务数据 并进行拼接
	function lk_indexFindTask(ttid,limit,mark,indexNewMark){
		//indexNewMark  是否是首页查新任务消息的标记,如果为0 要清空本页式的填充
		$.ajax({
			type:"POST",
			url:"task.action",
			data:"op=indexFindTask&ttid="+ttid+"&limit="+limit+"&mark="+mark,
			dataType:"JSON",
			success: function(data){
				if(data.code==1){
					var tablestring="";
					for(var i=0;i<data.obj.length;i++){
						var item=data.obj[i];
						//对任务的发布时间戳进行裁剪
						item.tsendtime=lk_showTime( (item.tsendtime).substring(0, 10) );
						//TODO判断该任务的关注
						var lk_task_status=item.iscare;//关注状态
						var lk_task_status_total=item.tcarenum;//关注总人数
						//将数字用括号包裹起来
						if(lk_task_status_total!=""){
							lk_task_status_total="("+lk_task_status_total+")";
						}
						//判断该任务是否有人接收
						var lk_acceptStatus="接收";
						if(item.taccid!="null"&& item.taccid!=null){
							lk_acceptStatus="已接收";
						}
						//中间加其他的html代码
						tablestring+='<div class="yhj_content_maincontent_center_conternt"><div class="lk_taskInfo_person"><div class="lk_taskInfo_person_head"><img src="images/headphotos/'+item.uimage+'"/></div><div class="lk_taskInfo_person_info"><div class="lk_taskInfo_person_info_name">'+item.ualais+'</div><div class="lk_taskInfo_person_info_type"><ul><li>'+item.ttname+'</li></ul></div></div></div><div class="lk_index_taskInfo"><div class="lk_index_taskInfo_describe"><ul><li>'+item.tsendtime+'</li><li>天气:'+item.tweather+'</li><li>悬赏积分:'+item.treward+'</li><li>地点:'+item.taddr+'</li></ul></div><div class="lk_preview_img_moreInfo"><a>&nbsp;&nbsp;任务详情:</a><span class="lk_preview_img_ControlDiv_ico">点击展开</span></div><div class="lk_preview_img_moreInfoDiv">'+item.tmore+'</div><div class="lk_preview_img_ControlDiv"><a>&nbsp;&nbsp;任务相关图片:</a><span class="lk_preview_img_ControlDiv_ico">点击展开</span></div><div class="lk_preview_img_small"><img class="lk_small_img" src="images/taskPhoto/'+item.tphoto+'"/></div><div class="lk_index_taskInfo_buttonDiv"><div class="lk_index_taskInfo_button_1" tid="'+item.tid+'">'+lk_acceptStatus+'</div><div  class="lk_index_taskInfo_button_line"></div><div class="lk_index_taskInfo_button_2" status="'+lk_task_status+'" tid="'+item.tid+'">'+lk_task_status+lk_task_status_total+'</div><div  class="lk_index_taskInfo_button_line"></div><div class="lk_index_taskInfo_button_3" tid="'+item.tid+'">评论</div><div  class="lk_index_taskInfo_button_line"></div><div class="lk_index_taskInfo_button_4" tid="'+item.tid+'">屏蔽</div></div><div class="lk_index_taskInfo_discuss"><div class="lk_index_taskInfo_discuss_triangle"></div><div class="lk_index_taskInfo_discuss_input"><div class="lk_index_taskInfo_discuss_input_div"><div class="lk_index_taskInfo_discuss_input_div_head"><img class="lk_index_taskInfo_discuss_input_div_head_img" src="images/lk_cool_effects_img1.gif"/></div><div class="lk_index_taskInfo_discuss_input_div_input"><input type="text" maxlength="140"/></div><div class="lk_index_taskInfo_discuss_input_div_send" tid="'+item.tid+'">评论</div></div></div><div class="lk_index_taskInfo_discuss_list"><div class="lk_index_taskInfo_discuss_list_type"><ul><li>全部</li><li>|</li><li>热门</li></ul></div><div class="lk_reply_list_show"></div><div class="lk_index_taskInfo_skip"><a href="task.action?op=taskdetail&tid='+item.tid+'">查看该任务全部评论</a></div></div></div></div></div>';
					}
					//alert(tablestring);
					//$("#lk_task_list_show").html(tablestring);
					if(data.msg=="0" || indexNewMark=="0"){//是否要清空当前页面数据的判断
						$("#lk_task_list_show").html(tablestring);
					}else{
						$("#lk_task_list_show").html($("#lk_task_list_show").html()+tablestring);
					}
					//为新刷出来的内容绑定事件
					lk_preview_bind();
					lk_reply_bind();
					 //如果登陆了,将评论区域的默认头像改为用户的头像
					lk_changeUserPhoto();
					
				}else if(data.code==-1){
					$("#lk_task_list_show").html("");
					sweetAlert("对不起", "当前条件下没有对应的任务数据哦!", "error");
				}
			}
		});
	}
	

	function flush(){//刷新
		//查询出新的数据
		//将查询出来的数据添加到任务块中
		$("#lk_task_list_show_refreshTip").fadeOut("1000");
		var limit=$(".yhj_content_maincontent_center_smallcontent_select:eq(0)").attr("limit");
		var ttid=$(".yhj_content_maincontent_left_select:eq(0)").attr("ttid");
		if($("#lk_task_list_show_refreshTip h1").text()!="当前条件下已经没有新的任务数据了"){
			$.ajax({
				type:"POST",
				url:"task.action",
				data:"op=indexFindTask&ttid="+ttid+"&limit="+limit,
				dataType:"JSON",
				success: function(data){
					if(data.code==1){
						var tablestring="";
						for(var i=0;i<data.obj.length;i++){
							var item=data.obj[i];
							//对任务的发布时间戳进行裁剪
							item.tsendtime=lk_showTime( (item.tsendtime).substring(0, 10) );
							//TODO判断该任务的关注
							var lk_task_status=item.iscare;//关注状态
							var lk_task_status_total=item.tcarenum;//关注总人数
							//将数字用括号包裹起来
							if(lk_task_status_total!=""){
								lk_task_status_total="("+lk_task_status_total+")";
							}
							//判断该任务是否有人接收
							var lk_acceptStatus="接收";
							if(item.taccid!="null"&&item.taccid!=null){
								lk_acceptStatus="已接收"
							}
							//中间加其他的html代码
							tablestring+='<div class="yhj_content_maincontent_center_conternt"><div class="lk_taskInfo_person"><div class="lk_taskInfo_person_head"><img src="images/headphotos/'+item.uimage+'"/></div><div class="lk_taskInfo_person_info"><div class="lk_taskInfo_person_info_name">'+item.ualais+'</div><div class="lk_taskInfo_person_info_type"><ul><li>'+item.ttname+'</li></ul></div></div></div><div class="lk_index_taskInfo"><div class="lk_index_taskInfo_describe"><ul><li>'+item.tsendtime+'</li><li>天气:'+item.tweather+'</li><li>悬赏积分:'+item.treward+'</li><li>地点:'+item.taddr+'</li></ul></div><div class="lk_preview_img_moreInfo"><a>&nbsp;&nbsp;任务详情:</a><span class="lk_preview_img_ControlDiv_ico">点击展开</span></div><div class="lk_preview_img_moreInfoDiv">'+item.tmore+'</div><div class="lk_preview_img_ControlDiv"><a>&nbsp;&nbsp;任务相关图片:</a><span class="lk_preview_img_ControlDiv_ico">点击展开</span></div><div class="lk_preview_img_small"><img class="lk_small_img" src="images/taskPhoto/'+item.tphoto+'"/></div><div class="lk_index_taskInfo_buttonDiv"><div class="lk_index_taskInfo_button_1" tid="'+item.tid+'">'+lk_acceptStatus+'</div><div  class="lk_index_taskInfo_button_line"></div><div class="lk_index_taskInfo_button_2" status="'+lk_task_status+'" tid="'+item.tid+'">'+lk_task_status+lk_task_status_total+'</div><div  class="lk_index_taskInfo_button_line"></div><div class="lk_index_taskInfo_button_3" tid="'+item.tid+'">评论</div><div  class="lk_index_taskInfo_button_line"></div><div class="lk_index_taskInfo_button_4" tid="'+item.tid+'">屏蔽</div></div><div class="lk_index_taskInfo_discuss"><div class="lk_index_taskInfo_discuss_triangle"></div><div class="lk_index_taskInfo_discuss_input"><div class="lk_index_taskInfo_discuss_input_div"><div class="lk_index_taskInfo_discuss_input_div_head"><img class="lk_index_taskInfo_discuss_input_div_head_img" src="images/lk_cool_effects_img1.gif"/></div><div class="lk_index_taskInfo_discuss_input_div_input"><input type="text" maxlength="140"/></div><div class="lk_index_taskInfo_discuss_input_div_send" tid="'+item.tid+'">评论</div></div></div><div class="lk_index_taskInfo_discuss_list"><div class="lk_index_taskInfo_discuss_list_type"><ul><li>全部</li><li>|</li><li>热门</li></ul></div><div class="lk_reply_list_show"></div><div class="lk_index_taskInfo_skip"><a href="task.action?op=taskdetail&tid='+item.tid+'">查看该任务全部评论</a></div></div></div></div></div>';
						}
						//$("p").appendTo( $("#lk_task_list_show") );
						if(data.msg=="0"){//是否要清空当前页面数据的判断
							$("#lk_task_list_show").html(tablestring);
						}else{
							$("#lk_task_list_show").html($("#lk_task_list_show").html()+tablestring);
						}
						//为新刷出来的内容绑定事件
						lk_preview_bind();
						lk_reply_bind();
						 //如果登陆了,将评论区域的默认头像改为用户的头像
						lk_changeUserPhoto();
						
					}else if(data.code==-1){
						var tip=$("#lk_task_list_show_refreshTip h1").text();
						$("#lk_task_list_show_refreshTip h1").text("当前条件下已经没有新的任务数据了");
						$("#lk_task_list_show_refreshTip").fadeIn("1000");
					}else{
						sweetAlert(data.msg);
					}
				}
			});
		}
	}